package com.liu.netty.netty;

import com.liu.netty.pojo.Message;
import com.liu.netty.util.MessageUtil;

public class ProtocolContant {

    public static final  String  COMMAND_STYLE_ONE = "1";
    public static final  String  COMMAND_STYLE_TWO = "2";
    public static final  String  COMMAND_STYLE_THREE = "3";

    public static final  String UP_CAMWAY = "up";
    public static final  String DWON_CAMWAY = "dowm";

    public  static   String getCamWay(String camway){
        if (camway.equalsIgnoreCase("1")){
            return UP_CAMWAY;

        }else if (camway.equalsIgnoreCase("2")){
            return DWON_CAMWAY;
        }else {
            return "";

        }
    }

    /**
     *
     * @param dataId      类型 1-9 中
     * @param taskId     任务编号
     * @param address   设备地址
     * @param resetFlag 1 复位应用程序
     * @param camway  1 上  2 下
     * @return
     */
    public static  String getCommandFromType(int dataId,String taskId,String address,String resetFlag,String camway){
        String command ="";
        switch (dataId){
            case 1://设备复位

                command=command="###<TaskID="+taskId+";TaskFlag=1;TaskContent{ObjectAddress="+address+";CommandStyle=2;DataID=4;DataContent<ResetFlg="+resetFlag+">}>###";
                break;
            case 2://设置参数
                command="###<TaskID="+taskId+";TaskFlag=1;TaskContent{ObjectAddress="+address+";CommandStyle=2;DataID=3;DataContent<>}>###";
                break;
            case 3://读取参数
                command="###<TaskID="+taskId+";TaskFlag=1;TaskContent{ObjectAddress="+address+";CommandStyle=2;DataID=3;DataContent<>}>###";
                break;
            case 4://读取软件版本号
                command="###<TaskID="+taskId+";TaskFlag=1;TaskContent{ObjectAddress="+address+";CommandStyle=2;DataID=4;DataContent<>}>###";
                break;
            case 5://设置时间
                command="";
                break;
            case 6://读取时钟
                command="###<TaskID="+taskId+";TaskFlag=1;TaskContent{ObjectAddress="+address+";CommandStyle=2;DataID=6;DataContent<>}>###";
                break;
            case 7://读取自检日志
                command="###<TaskID="+taskId+";TaskFlag=1;TaskContent{ObjectAddress="+address+";CommandStyle=2;DataID=7;DataContent<>}>###";
                break;
            case 8://读取传感器数据
                command="###<TaskID="+taskId+";TaskFlag=1;TaskContent{ObjectAddress="+address+";CommandStyle=2;DataID=8;DataContent<>}>###";
                break;
            case 9://控制摄像头拍照
                command="###<TaskID="+taskId+";TaskFlag=1;TaskContent{ObjectAddress="+address+";CommandStyle=2;DataID=9;DataContent<CamWay="+camway+">}>###";
                break;
        }

        return command;
    }






}
